<template>
	<view class="content">
		<view style="height: 200rpx;width: 100%;background-color: #1262DB;"></view>
		<view class="wid90 mar borRad20 box" style="height: 260rpx;background-color: #fff;margin-top: -130rpx;">
			<view class="dis disAl hei60" style="justify-content: flex-end;width: 100%;">
				<image src="../../static/personalCenter/bianji.png" @click="tiaozhuan('/pages/personalCenter/edit')" 
					style="width: 32rpx;height: 32rpx;margin-right: 30rpx;"></image>
				<image src="../../static/personalCenter/shebei.png" 
					style="width: 36rpx;height: 30rpx;margin-right: 30rpx;"></image>
			</view>
			<view class="wid80 mar dis disAl">
				<image :src="userinfo.avatar" style="width: 124rpx;height: 124rpx;" class="borRad50"></image>
				<view style="margin-left: 40rpx;">
					<view style="" class="foSi50">{{userinfo.nickname}}</view>
					<view style="color: #7C7C7C;" class="foSi30 mar-top10">{{userinfo.mobile}}</view>
					<view style="" class="foSi25 mar-top10">下属成员：{{userinfo.subordinate}}人</view>
				</view>
			</view>
		</view>
		<view style="height: 70rpx;background-color: #C5DBFC;" class="mar-top30 mar-bott30">
			<view class="wid90 mar dis disAl hei100">
				<view style="width: 20%;">
					<image src="../../static/personalCenter/gonggao.png" style="width: 44rpx;height: 40rpx;" class="mar-left10"></image>
				</view>
				<swiper class="wid80 hei100" :autoplay="true" :vertical="true" :circular='true'>
					<swiper-item v-for="(item,index) in 10" :key="index" class="wh100 dis disAl">
						<view class="foSi25" style="color: #1262DB;">{{userinfo.user_center_notes}}</view>
					</swiper-item>
				</swiper>
			</view>
		</view>
		<view class="wid90 mar borRad20" style="height: 280rpx;background-color: #fff;">
			<view class="wid90 mar dis disAl" style="height: 141rpx;justify-content: space-around;">
				<view class="textCen" style="width: 33.33%;" @click="tiaozhuan('/pages/detected/detected')">
					<view class="foSi50" style="color: #1262DB;">{{userinfo.today_testing}}</view>
					<view class="foSi25" style="color: #7C7C7C;">今日已检测</view>
				</view>
				<view class="textCen poRel" style="width: 33.33%;" @click="tiaozhuan('/pages/IncomeDetail/IncomeDetail')">
					<view v-if="!yxTrue" class="foSi40" style="color: #1262DB;">****</view>
					<view v-if="yxTrue" class="foSi40" style="color: #1262DB;">￥{{parseFloat(userinfo.today_income).toFixed(2)}}</view>
					<image v-if="!yxTrue" @click.stop="yxTrue = !yxTrue" src="../../static/personalCenter/yincang.png"
						style="width: 31rpx;height: 20rpx;right: -10rpx;top: 15rpx;" class="poAbs"></image>
					<image v-if="yxTrue" @click.stop="yxTrue = !yxTrue" src="../../static/personalCenter/xianshi.png" 
						style="width: 31rpx;height: 20rpx;right: -10rpx;top: 15rpx;" class="poAbs"></image>
					<view class="foSi25" style="color: #7C7C7C;">今日总收益</view>
				</view>
				<view class="textCen" style="width: 33.33%;">
					<view class="foSi50" style="color: #1262DB;">{{userinfo.teamnum}}</view>
					<view class="foSi25" style="color: #7C7C7C;">团队成员</view>
				</view>
			</view>
			<view style="background-color: #F0F0F0;height: 1rpx;"></view>
			<view class="wid90 mar dis disAl" style="height: 140rpx;justify-content: space-around;">
				<view class="textCen" style="width: 33.33%;">
					<view v-if="!yxTrue" class="foSi40" style="color: #1262DB;">****</view>
					<view v-if="yxTrue" class="foSi40" style="color: #1262DB;">￥{{parseFloat(userinfo.divide_into).toFixed(2)}}</view>
					<view class="foSi25" style="color: #7C7C7C;">检测收益</view>
				</view>
				<view class="textCen" style="width: 33.33%;">
					<view v-if="!yxTrue" class="foSi40" style="color: #1262DB;">****</view>
					<view v-if="yxTrue" class="foSi40" style="color: #1262DB;">￥{{parseFloat(userinfo.cost).toFixed(2)}}</view>
					<view class="foSi25" style="color: #7C7C7C;">试剂返还</view>
				</view>
				<view class="textCen" style="width: 33.33%;">
					<view v-if="!yxTrue" class="foSi40" style="color: #1262DB;">****</view>
					<view v-if="yxTrue" class="foSi40" style="color: #1262DB;">￥0.00</view>
					<view class="foSi25" style="color: #7C7C7C;">仪器押金</view>
				</view>
			</view>
		</view>
		<view class="wid90 mar borRad20 mar-top30" style="background-color: #fff;">
			<view v-if="group_id == 3">
				<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/clinic/add')">
					<view class="dis">
						<view class="dis disJuC" style="width: 75rpx;">
							<image src="../../static/personalCenter/zensuo.png" style="width: 44rpx;height: 44rpx;"></image>
						</view>
						<view>新增诊所</view>
					</view>
					<uni-icons type="forward" size="20" color="#616363"></uni-icons>
				</view>
				<view class="xhx"></view>
				<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/clinic/clinic')">
					<view class="dis">
						<view class="dis disJuC" style="width: 75rpx;">
							<image src="../../static/personalCenter/wdzensuo.png" style="width: 50rpx;height: 40rpx;"></image>
						</view>
						<view>我的诊所</view>
					</view>
					<uni-icons type="forward" size="20" color="#616363"></uni-icons>
				</view>
				<view class="xhx"></view>
			</view>
			<view v-if="group_id != 3">
				<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/salesman/add')">
					<view class="dis">
						<view class="dis disJuC" style="width: 75rpx;">
							<image src="../../static/personalCenter/tianjia.png" style="width: 43rpx;height: 44rpx;"></image>
						</view>
						<view>新增业务员</view>
					</view>
					<uni-icons type="forward" size="20" color="#616363"></uni-icons>
				</view>
				<view class="xhx"></view>
			</view>
			<view class="wid90 mar hei87 dis disAl disJuB"  @click="tiaozhuan('/pages/myGroup/myGroup')">
				<view class="dis">
					<view class="dis disJuC" style="width: 75rpx;">
						<image src="../../static/personalCenter/tuandui.png" style="width: 50rpx;height: 39rpx;"></image>
					</view>
					<view>我的团队</view>
				</view>
				<uni-icons type="forward" size="20" color="#616363"></uni-icons>
			</view>
			<view class="xhx"></view>
			<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/wallet/wallet')">
				<view class="dis">
					<view class="dis disJuC" style="width: 75rpx;">
						<image src="../../static/personalCenter/qianbao.png" style="width: 38rpx;height: 38rpx;"></image>
					</view>
					<view>我的钱包</view>
				</view>
				<uni-icons type="forward" size="20" color="#616363"></uni-icons>
			</view>
			<view class="xhx"></view>
			<!-- <view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/purchase/purchase')">
				<view class="dis">
					<view class="dis disJuC" style="width: 75rpx;">
						<image src="../../static/personalCenter/jinhuo.png" style="width: 43rpx;height: 43rpx;"></image>
					</view>
					<view>我要进货</view>
				</view>
				<uni-icons type="forward" size="20" color="#616363"></uni-icons>
			</view>
			<view class="xhx"></view>
			<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/purchase/myOrder')">
				<view class="dis">
					<view class="dis disJuC" style="width: 75rpx;">
						<image src="../../static/personalCenter/dingdan.png" style="width: 34rpx;height: 37rpx;"></image>
					</view>
					<view>采购订单</view>
				</view>
				<uni-icons type="forward" size="20" color="#616363"></uni-icons>
			</view>
			<view class="xhx"></view> -->
			<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/personalCenter/mydevice')">
				<view class="dis">
					<view class="dis disJuC" style="width: 75rpx;">
						<image :src="url+'wechatimg/device.png'" style="width: 34rpx;height: 37rpx;"></image>
					</view>
					<view>设备管理</view>
				</view>
				<uni-icons type="forward" size="20" color="#616363"></uni-icons>
			</view>
			<view class="xhx"></view>
			<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/personalCenter/switchaccounts')">
				<view class="dis">
					<view class="dis disJuC" style="width: 75rpx;">
						<image :src="url+'wechatimg/qhzh.png'" style="width: 48rpx;height: 48rpx;"></image>
					</view>
					<view>切换账号</view>
				</view>
				<uni-icons type="forward" size="20" color="#616363"></uni-icons>
			</view>
			<view class="xhx"></view>
			<view class="wid90 mar hei87 dis disAl disJuB" @click="tiaozhuan('/pages/personalCenter/clinicedit')">
				<view class="dis">
					<view class="dis disJuC" style="width: 75rpx;">
						<image :src="url+'wechatimg/clinic.png'" style="width: 34rpx;height: 37rpx;"></image>
					</view>
					<view>临时诊所(虚拟演示)</view>
				</view>
				<uni-icons type="forward" size="20" color="#616363"></uni-icons>
			</view>
		</view>
		<view style="height: 50rpx;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				yxTrue: false,
				userinfo: '',
				url: this.global.url,
				group_id: 1,
			}
		},
		onShow() {
			this.getuserinfo()
			this.getGroupId()
		},
		methods: {
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				});
			},
			getGroupId(){
				var that = this
				uni.request({
				    url: that.global.url + 'api/user/getuserinfo',
				    method: "POST",
					header: {
						'token': uni.getStorageSync('token')
					},
				    data: {},
				    success(res) {
				        let result = res.data
				        if(result.code == 1){
							that.group_id = result.data.group_id
							console.log(result.data.group_id)
						}else{
				           uni.showToast({
				           	title: result.msg,
				           	icon: 'error'
				           })
				        }
				       
				    }
				})
			},
			getuserinfo(){
				var that = this
				uni.request({
				    url: that.global.url + 'api/user/index',
				    method: "POST",
					header: {
						'token': uni.getStorageSync('token')
					},
				    data: {},
				    success(res) {
				        let result = res.data
				        if(result.code == 1){
							that.userinfo = result.data
						}else{
							uni.removeStorageSync('userinfo')
							uni.removeStorageSync('token')
							// uni.setStorageSync('userinfo', result.data.userinfo)
							// // 存用户信息
							// uni.setStorageSync('token', result.data.userinfo.token)
				           uni.showToast({
				           	title: result.msg,
				           	icon: 'error'
				           })
						   setTimeout(()=>{
							   uni.navigateBack()
						   },1000)
				        }
				       
				    }
				})
			},
		}
	}
</script>

<style>
	.content {
		background-color: #F0F0F0;
		min-height: 100vh;
	}
</style>
